# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

import logging
import threading

from odoo import api, models,fields, tools, registry

_logger = logging.getLogger(__name__)


# 结帐
class inout_carry_settle(models.TransientModel):
    _name = 'inout.carry.settle'

    calendar_id = fields.Many2one('resource.calendar', u'结帐期间', required=True, domain=[('inout_close', '!=', True)])

    @api.multi
    def inout_carry_settle(self):
        inout_obj = self.env['stock.month.balance']
        inout_obj.inout_carry_settle(self.calendar_id)
        return {'type': 'ir.actions.act_window_close'}


# 关帐
class inout_carry_close(models.TransientModel):
    _name = 'inout.carry.close'

    calendar_id = fields.Many2one('resource.calendar', u'关帐期间', required=True, domain=[('inout_close', '!=', True)])

    # 关帐，准确无误后点关帐按钮，弹出一个月份选择向导，选择一个月份进行关帐，并把关帐月份记录到关帐月份表中，
    # 关帐后不允许选择关帐月的强制日期进行操作，已关帐月份的结存表和进出汇总表都不允许修改。
    @api.multi
    def inout_period_close(self):
        self.calendar_id.inout_close = True
        return {'type': 'ir.actions.act_window_close'}


